<div  class="pubblog_home">
  <div id="publish_{$idtype}_{$id}" class="publishsharewrap">
    <div id="return_publish_{$idtype}_{$id}" style="display:none"></div>
    <form id="form_{$idtype}_{$id}" name="form_{$idtype}_{$id}" class="form-horizontal" action="{DZZSCRIPT}?mod=comment&op=ajax" method="post"  onsubmit="ajaxpost('form_{$idtype}_{$id}', 'return_publish_{$idtype}_{$id}','return_publish_{$idtype}_{$id}');" style="margin:0">
      <input type="hidden" name="formhash" value="{FORMHASH}" />
 	   <input type="hidden" name="replysubmit" value="true" />
      <input type="hidden" name="handlekey" value="publish_{$idtype}_{$id}" />
      <input type="hidden" name="cid" value="0" />
      <input type="hidden" name="id" value="$id" />
      <input type="hidden" name="idtype" value="$idtype" />
      <input type="hidden" name="module" value="$module" />
      <input type="hidden" name="allowattach" value="$_GET['allowattach']" />  
      <input type="hidden" name="allowat" value="$_GET['allowat']" />  
      <input type="hidden" name="allowsmiley" value="$_GET['allowat']" />             
      <div class="container_psw">
        <div class="textarea_cpsw">
          <div class="wrap_tcpsw">
            <textarea rows="" id="message_{$idtype}_{$id}" name="message" cols="" onkeyup="check_publish_enable('{$idtype}_{$id}')" tip="{lang said_two_sentences}" class="write_wtcpsw _bb_write_wtcpsw " style="overflow: hidden; word-wrap: break-word; resize: vertical;border:none;box-shadow:none;height:25px;">{lang said_two_sentences}</textarea>
          </div>
          <div id="publish_count_{$idtype}_{$id}" class="count_cpsw"> <span id="num_input_{$idtype}_{$id}" class="num_ccpsw">0</span>/<span class="leng_ccpsw">1000</span> </div>
        </div>
      </div>
      <div id="publish_action_{$idtype}_{$id}" class="action_cpsw">
        <ul class="list_acpsw">
        <!--{if $_GET[allowattach]>0}-->
       	   <li class="ament_lacpsw" style="position: relative; cursor: pointer;">
           <a id="upload_from_{$idtype}_{$id}" onclick="showMenu({'ctrlid':this.id,'evt':'click','layer':2});return false;" href="javascript:void(0);" title="" class="item_lacpsw">{lang typename_attach}/{lang photo}</a> 
           
           </li>
           <!--{/if}-->
            <!--{if $_GET[allowat]>0}-->
          <li class="at_lacpsw"><a id="at_home" href="javascript:void(0);" title="" class="item_lacpsw">{lang colleague}</a></li>
          <!--{/if}-->
         <!--{if $_GET[allowsmiley]>0}-->
          <li class="emotion_lacpsw"><a href="javascript:;"  class="item_lacpsw" id="message_{$idtype}_{$id}sml" onclick="showMenu({'ctrlid':this.id,'evt':'click','layer':2});return false;">{lang face}</a></li>
           <script type="text/javascript" reload="1"> 
			jcLoader().load({  
				type:'js', 
				ids:'js_smilies', 
				url:'static/js/smilies.js?{VERHASH}'  
			},function(){  
			   smilies_show('message_{$idtype}_{$id}_sml_div','{$_G[setting][smcols]}', 'message_{$idtype}_{$id}');
			});
        </script>
          <!--{/if}-->
        </ul>
         <a id="publish_submit_{$idtype}_{$id}" class="btn btn-primary btn-sm" type="button" disabled="disabled" title="{lang publish}(Ctrl+Enter)" href="javascript:void(0);" ><b>{lang publish}</b></a> 
      </div>
       <div id="attachmentViewBox_{$idtype}_{$id}" class="attachmentContainer clearfix"> </div>
    </form>
    <div class="actionUploadAttachment tobody" id="upload_from_{$idtype}_{$id}_menu" style="display:none">
      <!--{if $_GET[allowattach]>=2 }--><div class="local_auatth" style="position:relative;overflow:hidden"> <a href="javascript:void(0);" hidefocus onclick="jQuery(this).parent().parent().hide();">{lang web_upload}
        <input id="fileupload_{$idtype}_{$id}" type="file" name="files[]" multiple >
        </a> </div><!--{/if}-->
        <!--{if $_GET[allowattach]==1 || $_GET[allowattach]>2}-->
      <div class="own_auatth" style=""><a href="javascript:void(0);" hidefocus onclick="uploadfrom_desktop('{$idtype}_{$id}');jQuery(this).parent().parent().hide();">{lang choose_from_my_file}</a></div> 
      <!--{/if}-->
    </div>
  </div>
</div>
<script type="text/javascript" src="dzz/comment/scripts/comment.js?{VERHASH}"></script>
<script type="text/javascript" reload="1">
jQuery(document).ready(function(e) {
	jQuery('#upload_from_{$idtype}_{$id}_menu.tobody').removeClass('tobody').appendTo('#append_parent');
	jQuery('#publish_submit_{$idtype}_{$id}').click(function(){
		var val=jQuery('#message_{$idtype}_{$id}').val();
			if(strlen(val)>0 && strlen(val)<1000){
			document.getElementById('form_{$idtype}_{$id}').onsubmit();
		}
	});
	jQuery(document).on('keydown','#form_{$idtype}_{$id}',function(event){
		if(event.ctrlKey && event.keyCode == 13) {
			document.getElementById('form_{$idtype}_{$id}').onsubmit();
		}
	});
	
	jQuery('#message_{$idtype}_{$id}').on('focus',function(){
		if(this.value==jQuery(this).attr('tip')){
			this.value='';
		};
		
		jQuery(document).on('click.publish_{$idtype}_{$id}',function(e){
			e=e?e:window.event;
			var obj = e.srcElement ? e.srcElement :e.target;
			if(obj.type=="text" || obj.type=="textarea" || obj.type=="a"){
				return true;
			}
			if(!jQuery(obj).closest('#publish_{$idtype}_{$id}').length){
				jQuery(document).off('.paublish_{$idtype}_{$id}');
				if(jQuery('#message_{$idtype}_{$id}').val()==''){
					jQuery('#message_{$idtype}_{$id}').val(jQuery('#message_{$idtype}_{$id}').attr('tip'));
				}
			}
		});
	});
	jcLoader().load({  
				type:'js', 
				ids:'caret,atwho', 
				url:'static/atwho/js/jquery.caret.js?{VERHASH},static/atwho/js/jquery.atwho.js?{VERHASH}'  
			},function(){  
			   
			
	   <!--{if $_GET[allowat]>0}-->
		jQuery('#at_home').on('mousedown',function(){
			if(jQuery('#message_{$idtype}_{$id}').val()==jQuery('#message_{$idtype}_{$id}').attr('tip')){
				document.getElementById('message_{$idtype}_{$id}').value='@';
			}else{
				document.getElementById('message_{$idtype}_{$id}').value+='@';
			}
			jQuery('#message_{$idtype}_{$id}').caret('pos',document.getElementById('message_{$idtype}_{$id}').value.length);
			jQuery('#message_{$idtype}_{$id}').focus().atwho('run');
			return false;
		});
		<!--{/if}-->			
		
		jQuery('#message_{$idtype}_{$id}').TextAreaExpander(25,99999);
		<!--{if $_GET[allowattach]>=2}-->
		var attachextensions='{eval echo implode('|',$space[attachextensions]);}';
		if(attachextensions=='') attachextensions="\.*$";
		else attachextensions="(\.|\/)("+(attachextensions)+")$";
		jQuery('#fileupload_{$idtype}_{$id}').fileupload({
			url: DZZSCRIPT+'?mod=comment&op=ajax&do=upload',
			dataType: 'json',
			autoUpload: true,
			maxChunkSize:(parseInt('{$_G[setting][maxChunkSize]}') || 2000000), //2M
			dropZone:jQuery('#publish_{$idtype}_{$id}'),
			pasteZone:jQuery('#publish_{$idtype}_{$id}'),
			maxFileSize: parseInt('{$space[maxattachsize]}')>0?parseInt('{$space[maxattachsize]}'):null, // 5 MB
			acceptFileTypes:new RegExp(attachextensions,'i'),
			add:function(e,data){
				 data.context = jQuery('<div/>').appendTo('#attachmentViewBox_{$idtype}_{$id}');
				jQuery.each(data.files, function (index, file) {
					if(!file.name) file.name='clipboardData.png';
					var html='';
						html+=' <div  class="attachment_previewer">';
						html+='     <div class="attachmentviewbox">';
						html+='         <div class="view_attvb clearfix">';
						html+='           <div class="ico_vattvb "><img alt="'+file.name+'" src="dzz/images/default/upload_failure.png" style="height:50px"></div>';
						html+='  		  <div class="ico_vattvb_right">';
						html+='            	<div class="ico_name">'+file.name+'</div>';
						html+='             <div class="progress  active" style="margin:0;" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>';
						html+='          </div>';
						
						html+='      	</div>';
						html+='    </div>';
						html+=' </div>';
					
					jQuery(html).appendTo(data.context);
				});
				
				data.process().done(function () {
					data.submit();
				});
				
			},
			progress: function (e,data){
				 var index = 0;//data.index,
				// file = data.files[index],
				var  node = jQuery(data.context.children()[index]);
				
				  var progress = parseInt(data.loaded / data.total * 100, 10);
					node.find('.progress-bar').css(
						'width',
						progress + '%'
					);
			},
			done: function (e, data) {
				jQuery.each(data.result.files, function (index, file) {
					if(file.error){
						jQuery(data.context.children()[index]).find('.progress').replaceWith('<span class="text-danger">'+file.error+'</span>');
					}else{
						feed_addAttach(file.data,jQuery(data.context.children()[index]),'{$idtype}_{$id}');
					}
				});
			}
		});
		<!--{/if}-->


		<!--{if $_GET[allowat]>0}-->
		var cachequeryMentions = [], itemsMentions;
		jQuery('#message_{$idtype}_{$id}').atwho({
			at: "@",
			//data: '{DZZSCRIPT}?mod=feed&op=ajax&do=getUserToJson',
			data: '{DZZSCRIPT}?mod=system&op=at&filter=1',
			callbacks:{
						remote_filter: function (query, render_view) {
							var thisVal = query,
							self = jQuery(this);
							if( !self.data('active') && thisVal.length >= 1 ){
								self.data('active', true);                            
								itemsMentions = cachequeryMentions[thisVal]
								if(typeof itemsMentions == "object"){
									render_view(itemsMentions);
								}else
								{                            
									if (self.xhr) {
										self.xhr.abort();
									}
									self.xhr = jQuery.getJSON('{DZZSCRIPT}?mod=system&op=at&filter=1',{
										term: thisVal
									}, function(data) {
										cachequeryMentions[thisVal] = data
										render_view(data);
									});
								}                            
								self.data('active', false);                            
							}                    
						}
			},
			 tpl: "<li data-value='@[${name}:${id}]' title='${title}'><img src='${icon}'>&nbsp;${name}</li>",
			 search_key: "searchkey",
			 start_with_space: false,
			 limit: 5,
			 max_len: 20,
			 display_timeout: 300
		});
	 
		<!--{/if}-->
	});
});
function succeedhandle_publish_{$idtype}_{$id}(url, message, values) {
	var data= eval('(' + decodeURIComponent(values['data']) + ')');
	feed_publish(data,'{$idtype}_{$id}','{$_GET[targetid]}');
};
</script> 
